package com.zbec.mdrs.repository.jpa;

import com.zbec.mdrs.entity.history.History;
import com.zbec.mdrs.vo.HistoryVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by fxl on 2015/10/17.
 */
public interface HistoryDao extends PagingAndSortingRepository<History, Long>, JpaSpecificationExecutor<History> {
    History save(History history);

    List<History> findByBusinessMonthAndRecordStatusAndBusinessType (String businessMonth,String recordStatus,String businessType );

    @Query("select new com.zbec.mdrs.vo.HistoryVo(his.id,his.recordNumber,his.importDate,his.importBy,his.recordStatus,his.businessType,his.businessMonth)" +
            " from History his " +
            " order by his.id desc")
    Page<HistoryVo> findAllHistory( Pageable pageable);
}
